from core.support import set_cutscene, get_game
from core.item import Item
from core.action import Action

class Bullhorn(Item):
    def __init__(self):
        Item.__init__(self, "Bullhorn")    # do basic initialization for every item
        
        # build list of actions
        # are we going to do a swipe action?  or just check if the card is in inventory?
        # if we just check, then we don't need this action at all
        self.add_action(UseBullhorn)
    
    def get_description(self):
        return "Bullhorn"

# define actions for this item

class UseBullhorn(Action):
    def __init__(self):
        Action.__init__(self, "use_bullhorn")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Use Bullhorn"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    
    # which one are we doing here??
    def get_method(self):
        return "get"
    
    def is_enabled(self):
        game = get_game()
        if ((game.history[-1].get_id() == 'councilroom') or (game.history[-1].get_id() == 'gradlounge')):
            if (not game.history[-1].locked) & game.history[-1].solving:
                return False
            else:
                return True
        else:
            return True
    
    # only works in basement. add cutscene
    def do_action(self,game,room,request):
        if room.get_id() == 'gradlounge':
            #if room.treasure_locked:
                #if room.lock_rusty:
                    #set_cutscene("You try to turn the key but the lock appears to be rusted in place.")
                #else:
                    #set_cutscene("You turn the key and the lock turns with a grating sound.")
                    #room.treasure_locked = False
            #else:
                set_cutscene("You just yelled at the undergrad in the grad lounge, causing them to leave promptly. All the grad students in the lounge cheer. ")
        else:
            set_cutscene("What are you thinking? You can't just Yell Anywhere.")
        return